home *** CD-ROM | disk | FTP | other *** search
/ Champak 141 / (Vol 141) Oct 17 2011.iso / Games / Clueless.swf / scripts / PowerupDoubleDamage.as < prev    next >
Encoding:
Text File  |  2011-10-17  |  3.3 KB  |  110 lines

  1. package
  2. {
  3.    import Common.SoundManager;
  4.    import Forms.DressupForm;
  5.    import flash.display.*;
  6.    import flash.events.Event;
  7.    import flash.utils.*;
  8.    import org.flintparticles.actions.*;
  9.    import org.flintparticles.counters.*;
  10.    import org.flintparticles.easing.*;
  11.    import org.flintparticles.emitters.Emitter;
  12.    import org.flintparticles.energyEasing.*;
  13.    import org.flintparticles.initializers.*;
  14.    import org.flintparticles.renderers.*;
  15.    import org.flintparticles.zones.*;
  16.    
  17.    public class PowerupDoubleDamage extends Powerup
  18.    {
  19.        
  20.       
  21.       protected const NUM_PARTICLES:int = 100;
  22.       
  23.       internal var _dressupform:DressupForm;
  24.       
  25.       internal var _renderer:DisplayObjectRenderer;
  26.       
  27.       protected const PARTICLE_SPEED:int = 25;
  28.       
  29.       internal var _emitter:Emitter;
  30.       
  31.       protected const ZONE_WIDTH:int = 50;
  32.       
  33.       public var PartnerName:String = null;
  34.       
  35.       internal var _numAdded:int = 0;
  36.       
  37.       internal var _MCPartner:MCThumbnail;
  38.       
  39.       public function PowerupDoubleDamage()
  40.       {
  41.          _numAdded = 0;
  42.          PartnerName = null;
  43.          super();
  44.          _sName = "double";
  45.          _sDescription = "Doubles the value of the next match";
  46.          _MCPartner = new MCThumbnail();
  47.          _MCPartner.visible = false;
  48.          _MCPartner.gotoAndStop(1);
  49.          addEventListener(Event.ADDED_TO_STAGE,onAdded,false,0,true);
  50.          addEventListener(Event.REMOVED_FROM_STAGE,onRemoved,false,0,true);
  51.       }
  52.       
  53.       override public function init(param1:DressupLevelInfo) : void
  54.       {
  55.          var _loc2_:int = 0;
  56.          super.init(param1);
  57.          if(param1.getLevelPartners().length > 0)
  58.          {
  59.             _MCPartner.visible = true;
  60.             this.alpha = 0;
  61.             _loc2_ = int(Math.floor(Math.random() * param1.getLevelPartners().length));
  62.             PartnerName = param1.getLevelPartners()[_loc2_].Name;
  63.             trace(PartnerName);
  64.             _MCPartner.gotoAndStop(PartnerName);
  65.          }
  66.       }
  67.       
  68.       protected function onMoved(param1:Event) : void
  69.       {
  70.          _MCPartner.x = this.x - _MCPartner.width / 2;
  71.          _MCPartner.y = this.y - _MCPartner.height / 2;
  72.       }
  73.       
  74.       protected function onAdded(param1:Event) : void
  75.       {
  76.          this.parent.addChildAt(_MCPartner,this.parent.getChildIndex(this));
  77.          ++_numAdded;
  78.          onMoved(param1);
  79.       }
  80.       
  81.       override public function spawn() : Powerup
  82.       {
  83.          return new PowerupDoubleDamage();
  84.       }
  85.       
  86.       protected function onRemoved(param1:Event) : void
  87.       {
  88.          if(_numAdded > 0)
  89.          {
  90.             this.parent.removeChild(_MCPartner);
  91.             --_numAdded;
  92.          }
  93.       }
  94.       
  95.       protected function eraseEffect() : void
  96.       {
  97.       }
  98.       
  99.       override public function activate(param1:Array, param2:Array, param3:DressupForm, param4:DressupLevelInfo) : void
  100.       {
  101.          super.activate(param1,param2,param3,param4);
  102.          SoundManager.getInstance().playSound("PowerupBoyfriendSound");
  103.          param4.DoubleDamage = true;
  104.          param4.DoubleDamageTarget = this.PartnerName;
  105.          trace("Double damage if partner = " + PartnerName);
  106.          setTimeout(eraseEffect,3000);
  107.       }
  108.    }
  109. }
  110.